<template>
    <view class="box" style="padding: 20rpx; background: white; margin-bottom: 20rpx">
        <!-- 列表 -->
        <view>
            <view class="flex justify_content_between f_28 mb_24">
                <view class="cl_3377FF fw_bold">{{ item.order_text }}</view>
                <!-- <view class="cl_FF6401 fw_bold">已超时</view> -->
                <view class="cl_CCCED1" v-if="item.product_type==7">{{ item.createtime }}</view>
				<view class="cl_CCCED1" v-if="item.product_type==2">{{ item.createtime }}</view>
            </view>
			
            <view class="flex" @click="buybtn(item,1)" >
			
                <view>
                    <image class="shopImg" :src="item.specifications.goods_image" mode="widthFix"></image>
                </view>
                <view>
                    <view class="fw_bold f_32 listTitle" v-if="item.product_type==2">{{ item.specifications.license_plate_number}}</view>
					<view class="fw_bold f_32 listTitle" v-if="item.product_type==7">{{ item.specifications.product_name}}</view>
                    <view class="flex justify_content_between">
                        <view class="cl_999CA3 mr_24 f_28">{{item.lease}}</view>
                        <view class="cl_999CA3 mr_24 f_28">{{item.s_lease}}</view>
                    </view>
                    <view class="flex justify_content_end mt_40 f_28">
                        优惠￥{{item.coupon_price}} 合计
                        <text class="cl_FF6401">￥{{item.actual_price}}</text>
                    </view>
                </view>
            </view>
            <view class="flex justify_content_end mt_16">
				<view class="buy" @click="buybtn(item,1)" v-if="item.order_status==0">立即付款</view>
				<view class="cance" style="margin-left: 5px;" @click="q_order(item.id)" v-if="item.order_status==0">取消订单</view>
				<view class="flex btn" @click="y_q_order(item.id,1)" v-if="item.order_status==1&&item.rider_status==0">申请退款</view>
				<view class="flex btn" @click="y_q_order(item.id,1)" v-if="item.order_status==1&&item.rider_status==1">申请退款</view>
				<view class="flex btn" @click="dh(item,1)" v-if="item.order_status==1&&item.rider_status==0">导航到店</view>
				<view class="flex btn" @click="dh(item,1)" v-if="item.order_status==1&&item.rider_status==1">导航到店</view>
				<view class="flex btn" @click="y_q_order(item.id,1)" v-if="item.order_status==1&&item.rider_status==2">申请退款</view>
				<view class="flex btn" @click="y_q_order(item.id,1)" v-if="item.order_status==1&&item.rider_status==3">申请退款</view>
				<view class="flex btn" @click="y_q_order(item.id,2)" v-if="item.order_status==1&&item.rider_status==4">申请退款</view>
				<view class="flex btn" @click="delete_order(item.id,1)" v-if="item.order_status==1&&item.rider_status==4">删除订单</view>
				
            <!--    <view class="flex btn">
                    <view>订单申述</view>
                </view>
                <view class="flex btn">
                    <view>导航到店</view>
                </view>
                <view class="flex btn back_3377FF cl_fff" @click.stop="ReturnShow = true">
                    <view>使用完成</view>
                </view> -->
                <!-- <view class="flex btn" @click="CancelOrder">
            <view>取消订单</view>
          </view>
          <view class="flex btn back_3377FF cl_fff" @click.stop="buy">
            <view>立即付款</view>
          </view> -->
                <!-- <view class="flex btn">
		  	<view>删除订单</view>
		  </view>
		  <view class="flex btn back_3377FF cl_fff" @click="">
		  	<view>再来一单</view>
		  </view> -->
           <!-- <view class="flex btn">
		  	<view>取消售后</view>
		  </view> -->
	<!-- 	<view class="flex btn back_3377FF cl_fff"  v-if="item.order_status==1&&item.rider_status==1">
		  	<view>订单详情</view>
		  </view> -->
		  <!-- @click="tc(item.id)" -->
           <view class="flex btn back_3377FF cl_fff" @click="ti(),tcm=item.delivery_code,order_id=item.id"  v-if="item.order_status==1&&item.rider_status==0">
		  	<view>确认提车</view>
		  </view>
		<!--  <view class="flex btn back_3377FF cl_fff" @click="tc(item.id)" v-if="item.order_status==1&&item.rider_status==0">
		  	<view>提车码</view>
		  </view> -->
		  <view class="flex btn" style="background: #3377ff;color: #fff;" @click="user_wc(item.id)" v-if="item.rider_status==1||item.rider_status==2||item.rider_status==3">
		  	<view>使用完成</view>
		  </view>
		  <!-- <view class="flex btn" @click="user_wc(item.id)" >确认收货</view> -->
            </view>
			<u-popup :show="tc_show" :round="10" mode="center" @close="tc_close">
				<view class="tk_tc" >
					<view class="black_f_32 font_w_bold bor_b_48">{{title}}</view>
					<view class="bor_b_48 blue_f_52 " style="margin: 70rpx;color: #4F85F0;font-size: 24px;">#{{tcm}}#</view>
					<view class="tc_but white_f_32" @click="tc()" style="color: #fff;">确定</view>
				</view>
			</u-popup>
        </view>
    </view>
</template>

<script>
export default {
    name: 'order-item-lease',
    props: {
        item: {
            type: Object,
            default: () => {}
        }
    },
    data() {
        return {
            ReturnShow: false,
            PcarShow: false,
            type: 0, //0待发货，1待收货，2已完成，3售后中
            ProductType: 1 ,//0普通商品，1电池
			title:'',
			tcm:'',
			tc_show:false,
			order_id:0,
			
        };
    },
    methods: {
		dh(item){
			uni.openLocation({
				latitude: parseFloat(item.specifications.lat),
				longitude: parseFloat(item.specifications.lng),
				scale: 18
			});
		},
		ti(i) {
			this.title = '提车码'
			console.log('aaa');
			// this.tcm = 'hxuasxjhai'
			this.tc_show = true
		},
		tc_close() {
			this.tc_show = false
			// console.log('close');
		},
	
		//未支付取消
		q_order(id){
			this.$.ajax(1, "POST", "users/q_order", {
					id:id,
				}, (res) => {
					if(res.code==200){
						this.$.ti_shi(res.msg)
						 setTimeout(()=>{
							 this.$emit('handleGetOrderList')
						 },1000)
						 
					}else{
						this.$.ti_shi(res.msg)
					}
				})
		},
		
		
		delete_order(id){
			this.$.ajax(1, "POST", "users/delete_order", {
					order_id:id,
				}, (res) => {
					if(res.code==200){
						this.$.ti_shi(res.msg)
						 setTimeout(()=>{
							 this.tc_show = false
							 this.$emit('handleGetOrderList')
						 },1000)
						 
					}else{
						this.$.ti_shi(res.msg)
					}
				})
		},
		user_wc(id){
			this.$.ajax(1, "POST", "users/user_wc", {
					order_id:id,
				}, (res) => {
					if(res.code==200){
						this.$.ti_shi(res.msg)
						 setTimeout(()=>{
							 this.tc_show = false
							 this.$emit('handleGetOrderList')
						 },1000)
						 
					}else{
						this.$.ti_shi(res.msg)
					}
				})
		},
        // 待提车详情
        details(type) {
            console.log(1);
            if (this.ProductType == 0) {
                uni.navigateTo({
                    url: '/pages/me/MyOrder/CarRentalDetails?type=' + type
                });
            }
            if (this.ProductType == 1) {
                uni.navigateTo({
                    url: '/pages/me/MyOrder/BatteryCompleted'
                });
            }
        },
		//用户点击提车
		tc() {
		    this.$.ajax(1, "POST", "users/user_tc", {
		    		order_id:this.order_id,
		    		// lat:39.222,
		    		// lng:117.333,
		    	}, (res) => {
		    		if(res.code==200){
		    			this.$.ti_shi(res.msg)
		    			setTimeout(()=>{
		    				this.$emit('handleGetOrderList')
		    			},1000)
		    			 
		    		}else{
		    			this.$.ti_shi(res.msg)
		    		}
		    	})
		},
		buybtn(id,t) {
	
			if(id.rider_status==1||id.rider_status==2||id.rider_status==3||id.rider_status==4||id.order_status==0){
				uni.navigateTo({
				    url: '/pages/me/MyOrder/CarRentalDetails?id=' + id.id+'&t='+t
				});
			}
			if(id.rider_status==5){
				uni.navigateTo({
				    url: '/pages/me/MyOrder/CarAfterSales?id=' + id.id+'&t='+t
				});
			}
		    
		},
		//已支付取消
		y_q_order(id,t){
			uni.navigateTo({
			    url: '/pages/me/MyOrder/CarCancel?id=' + id+'&t=1'+'&is_type='+t
			});
		},
        // 售后详情
        details1() {
            uni.navigateTo({
                url: '/pages/me/MyOrder/CarAfterSales'
            });
        },
        // 查看评价
        evaluea() {
            uni.navigateTo({
                url: '/pages/me/MyOrder/orderEvaluation'
            });
        },
        add() {
            uni.navigateTo({
                url: '/pages/business/addProduct'
            });
        },
        add_zc() {
            uni.navigateTo({
                url: '/pages/business/CarRental'
            });
        }
    }
};
</script>

<style scoped lang="scss">
	.tk_tc {
		padding: 40rpx 32rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	
		.but_a {
			width: 298rpx;
			height: 100rpx;
			background: #F7F7F7;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			text-align: center;
			line-height: 100rpx;
		}
	
		.but_b {
			width: 298rpx;
			height: 100rpx;
			background: #3377FF;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			text-align: center;
			line-height: 100rpx;
		}
	
		.tk_jj {
			width: 622rpx;
	
			.input {
				background-color: #F7F7F7;
				width: 574rpx;
				// height: 92rpx;
				padding: 24rpx;
				border-radius: 16rpx;
			}
		}
	
		.tc_but {
			width: 622rpx;
			height: 100rpx;
			background: #3377FF;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			text-align: center;
			line-height: 100rpx;
		}
	}
.nameTitle {
    text-align: center;
}
.storeImg {
    width: 48rpx;
    height: 48rpx;
    border-radius: 8rpx 8rpx 8rpx 8rpx;
    margin-right: 8rpx;
}
.name {
    width: 574rpx;
    height: 92rpx;
    line-height: 92rpx;
    padding: 0 24rpx;
}

.nameBtn {
    width: 298rpx;
    height: 100rpx;
    line-height: 100rpx;
    text-align: center;
    display: inline-block;
    margin-top: 64rpx;
}
.userInfo {
    background: #f7f7f7;
    border-radius: 16rpx;
    font-size: 28rpx;
    padding: 8rpx 24rpx;
    margin-top: 26rpx;
    .info {
        padding: 8rpx 0;
    }
}
.listTitle {
    width: 400rpx;
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.list {
    background: white;
    border-radius: 24rpx;
    margin-top: 24rpx;
    padding: 24rpx;
    display: block;
    overflow: hidden;
}
.shopImg {
    width: 133.385rpx;
    height: 200rpx;
    border-radius: 16rpx;
    margin-right: 24rpx;
}
.tipbox {
    background: #f7f7f7;
    border-radius: 8rpx;
    color: #666b75;
    font-size: 28rpx;
    padding: 8rpx;
}
.tip {
    padding: 16rpx;
    border-radius: 8rpx;
}
.tipActive {
    background: white;
    color: #00091a;
    padding: 16rpx;
    border-radius: 8rpx;
}
.tab {
    color: #999ca3;
    font-size: 28rpx;
    margin: 19rpx;
}
.tabActive {
    color: #3377ff;
    font-size: 32rpx;
    margin: 19rpx;
    font-weight: bold;
}
.btn {
    height: 68rpx;
    line-height: 68rpx;
    padding: 0 30rpx;
    text-align: center;
    border: 2rpx solid #ccced1;
    border-radius: 16rpx;
    margin: 0 8rpx;
    font-size: 24rpx;
}
    .buy {
        width: 160rpx;
        height: 68rpx;
        line-height: 68rpx;
        border-radius: 8rpx;
        color: #ffffff;
        text-align: center;
        background: #3377ff;
        margin-left: 24rpx;
        margin-top: 24rpx;
    }
	.cance {
	    width: 160rpx;
	    height: 68rpx;
	    line-height: 68rpx;
	    border-radius: 8rpx;
	    color: #666b75;
	    text-align: center;
	    border: 2rpx solid #ccced1;
	    margin-top: 24rpx;
	}
</style>
